#ifndef _XMAPPINGNODELIBRARY_H_
#define	_XMAPPINGNODELIBRARY_H_
/*------------------------------------------------------------
2009/4/7 By YPC
  This is a data structure that collects all the mapping node types, including those 
  from vmlibrary.
--------------------------------------------------------------
*/


#include <vector>
#include "xMappingTree.h"

const int MAX_MAPPINGNODE_NO = 500 ;

typedef struct xMappingNodeTypeDescriptor_type {
	std::string _name ;
	std::string _category ;				// the type of a mapping node. it can be 
									//		"ubvm" "arith" "composite_vm" "collector" "constant" "counter" "metronome"
	                                // this type can be used by the mapping dialog to create category of mapping node
	bool _hidden ;                // should this mapping node type hidden from normal users?
									// for example, "wop" should be hidden and never used by user.
	std::string _description ;
	int _id ;						// if this mapping node type is a VM, it is the VMID associated with the vm
									// if this mapping node type is
	std::string _idname ;				// Any idname associated with the mapping node type
	std::string _compositebody_mds ;     // this is used by composite VM to store the _mds ;
	
	int in_para_no ;					    // the number of parameters in the constructor
	bool in_para_fixed ;					// true if this mapping node type have fixed parameter
	                                   
	std::vector<std::string> in_para_type ;		// the string can be "int" "int*" "string" "string*" "vm" "vms" "wop" "wops"
	std::vector<std::string> in_para_name ;		// the name of the parameter
	std::vector<int>    in_para_class ;      // can be DEFAULT - this port is by default
	                                    //        REQUIRED - this port must be linked 
	                                    //        HIDDEN   - special used by reference VM
	std::vector<std::string> in_default_value ;
	std::vector<int> in_para_category;		// can be CATEGORY_NAME, CATEGORY_POSITION, CATEGORY_COLOR, CATEGORY_SCALE, CATEGORY_ROTATION, CATEGORY_SIZE, CATEGORY_OTHER

	
	int out_para_no ;					// the number of parameters in the constructor
	bool out_para_fixed ;
	std::vector<std::string> out_para_type ;		// the string can be "int" "int*" "string" "string*" "vm" "vms" "wop" "wops"
	std::vector<std::string> out_para_name ;		// the name of the parameter
	std::vector<int>    out_para_class ;     // can be DEFAULT - this port is by default
	                                    //        REQUIRED - this port must be linked 
	                                    //        HIDDEN   - special used by reference VM
	std::vector<std::string> out_default_value ;	
	std::vector<int> out_para_category;		// can be CATEGORY_NAME, CATEGORY_POSITION, CATEGORY_COLOR, CATEGORY_SCALE, CATEGORY_ROTATION, CATEGORY_SIZE, CATEGORY_OTHER

} xMappingNodeTypeDescriptor ;

class xMappingNodeTypeLibrary {

private:	
	static xMappingNodeTypeLibrary *	_xmnt;
	static int          _xmnt_total;					// how many VMs are stored in this VMLibrary
	xMappingNodeTypeDescriptor    	_xmnt_library[MAX_MAPPINGNODE_NO] ;		// the array to store the vm information
	xMappingNodeTypeLibrary();

public:
	static xMappingNodeTypeLibrary* getInstance();
	/// destructor
	~xMappingNodeTypeLibrary();

	xMappingNodeTypeDescriptor* get_xmnt_descriptor(int index);
	xMappingNodeTypeDescriptor* get_xmnt_descriptor(std::string mappingnode_name);
	int get_xmnt_descriptor_index(std::string name);
	int get_xmnt_no() { return _xmnt_total; }

	/** given a xMappingTree, this method add a composite vm to xMappingNodeTypeLibrary */

    void add_compositevm_from_xMappingTree(std::string vmname, std::string category, std::string description, xMappingTree* xmt, bool hidden = false ) ;
	void add_compositevm_from_xMappingTree(std::string vmname, std::string category, std::string description, std::string mds, bool hidden = false ) ;
	void add_typemapping_from_xMappingTree( const std::string & type, const std::string & description, xMappingTree * xmt );
	void load_vm_descriptors();
	void load_internal_mappingnode() ;
	void load_arithmetic_node();
	void delete_vm_from_xmnt_library(std::string vmname);	// added by howway
};

#endif 

